package no.uib.kwikktaim.utils;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import java.util.ArrayList;

/**
 * Class for converting byte arrays from primitive to non-primitive types.
 * Used in some arraylists when serializing images.
 *
 */
public class ByteConvertor {

	/**
	 * Turns Byte[] into byte[] (Needed for ArrayLists)
	 */
	public static byte[] byteToByte(Byte[] list) {
		byte[] newList = new byte[list.length];
		for (int i = 0; i < list.length; i++) {
			newList[i] = list[i];
		}
		return newList;
	}

	/**
	 * Turns byte[] into Byte[] (Needed for ArrayLists)
	 * @param list
	 * @return
	 */
	public static Byte[] byteFromByte(byte[] list) {
		Byte[] newList = new Byte[list.length];
		for (int i = 0; i < list.length; i++) {
			newList[i] = list[i];
		}
		return newList;
	}

}
